/** Lachlan Hewson-Doherty (h201384171)
 *  Diploma of Digital and Interactive Games
 *  lachlan_doherty@live.com.au
 *  2013
 */


package cabbage.controller;



import java.sql.SQLException;

import cabbage.database.operations.AccountCreationOps;
import cabbage.database.operations.AccountOps;
import cabbage.database.operations.CollectedGameplayOps;
import cabbage.database.operations.CollectibleCreationOps;
import cabbage.database.operations.CollectibleOps;
import cabbage.database.operations.LiveCollectibleCreationOps;
import cabbage.database.operations.LiveCollectibleOps;
import cabbage.database.operations.LocationOps;
import cabbage.database.operations.PlayerOps;
import cabbage.model.entities.CollectibleMasterBean;





public class Cupcake {
	

	
	
	

	
	
	private AccountCreationOps aco;
	private AccountOps ao;
	private CollectibleCreationOps cco;
	private CollectibleOps co;
	private LiveCollectibleOps lco;
	private LiveCollectibleCreationOps lcco;
	private LocationOps lo;
	private CollectedGameplayOps cgo;
	private PlayerOps po;
	
	
	
	
	
	
	

	
	
	
	public boolean login(String username, String password) throws SQLException {
		
		ao = new AccountOps();
		
		return ao.login
				(username, password);
	}
	
	
	
	
	
	
	
	// --------- INSERT METHODS --------- //

	
	
	public int insertNewAccount(String username, String firstname, String lastname, String emailaddress, String password) throws SQLException {
		
		aco = new AccountCreationOps();
		
		return aco.insertNewAccount
								(username, firstname, lastname, emailaddress, password);

	}
	
	
	public int insertNewPlayer(int accountid) throws SQLException {
		
		aco = new AccountCreationOps();
		
		return aco.insertNewPlayer
								(accountid);
		
	}
	
	
	public int insertNewFaculty() throws SQLException {
		
		cco = new CollectibleCreationOps();
		
		return cco.insertNewFaculty
								();
	}
	
	
	
	
	public int insertNewSkill(int facultyid) throws SQLException {
		
		cco = new CollectibleCreationOps();
		
		return cco.insertNewSkill
								(facultyid);
	}
	
	

	public int insertNewItem(int skillid, int facultyid) throws SQLException {
		
		cco = new CollectibleCreationOps();
		
		return cco.insertNewItem
								(skillid, facultyid);
	}
	
	
	public int insertNewCollectible(int item_id, int skill_id, int faculty_id, int collectibleCategory_id, String name, String description, String imageFileName) throws SQLException {
		
		cco = new CollectibleCreationOps();
		
		return cco.insertNewCollectible
								(item_id, skill_id, faculty_id, collectibleCategory_id, name, description, imageFileName);

	}
	
	
	public int insertNewLiveCollectible(int collectiblemaster_id, int location_id) throws SQLException {

		lcco = new LiveCollectibleCreationOps();
		
		return lcco.insertNewLiveCollectible
								(collectiblemaster_id, location_id);

	}
	
	
	public int insertCollected ( int livecollectible_id, int player_id ) throws SQLException{
		
		cgo = new CollectedGameplayOps();
		
		return cgo.insertCollected
								(livecollectible_id, player_id);
	}
	
	
	
	
	
	// --------- CHECK METHODS --------- //
	
	
	public boolean checkEmailAddressExists(String emailaddress) throws SQLException {
		
		ao = new AccountOps();
		
		return ao.checkEmailAddressExists
									(emailaddress);
	}
	
	
	public boolean checkIfCollectibleMasterExists( int collectiblemaster_id ) throws SQLException {
		
		co = new CollectibleOps();
		
		return co.checkIfCollectibleMasterExists
									(collectiblemaster_id);
	}
	
	
	
	public boolean checkLiveCollectibleExists ( int livecollectible_id ) throws SQLException {
		
		lco = new LiveCollectibleOps();
		
		return lco.checkLiveCollectibleExists
									(livecollectible_id);
	}
	
	
	
	public boolean checkLiveCollectibleExistsAtLocation( int collectiblemaster_id, int location_id) throws SQLException {
		
		lco = new LiveCollectibleOps();
		
		return lco.checkLiveCollectibleExistsAtLocation
									(collectiblemaster_id, location_id);
	}
	
	
	public boolean checkLocationExists( int location_id) throws SQLException {
		
		lo = new LocationOps();
		
		return lo.checkLocationExists
									(location_id);
	}
	
	
	public boolean checkPlayerHasCollected ( int livecollectible_id, int player_id ) throws SQLException {
		
		po = new PlayerOps();
		
		return po.checkPlayerHasCollected
									(livecollectible_id, player_id);
	}
	
	
	
	public boolean checkPlayerExists(int player_id) throws SQLException {
		
		po = new PlayerOps();
		
		return po.checkPlayerExists
									(player_id);
	}
	
	
	
	
	
	
	// --------- GET METHODS --------- //
	
	
	public CollectibleMasterBean getCollectibleMaster(String name) throws SQLException {
		
		co = new CollectibleOps();
		
		return co.getCollectibleMaster
							(name);
	}
	
	
	
	
	public CollectibleMasterBean getCollectibleMaster(int id) throws SQLException {
		
		co = new CollectibleOps();
		
		return co.getCollectibleMaster
							(id);
	}
	
	
	
	public CollectibleMasterBean getFacultyid(int facultyid) {
		
		co = new CollectibleOps();
		
		return co.getFacultyid
							(facultyid);
	}
	
	
	
	public CollectibleMasterBean getSkillid(int skillid) {
		
		co = new CollectibleOps();
		
		return co.getFacultyid
							(skillid);
	}
	
	
	
	public CollectibleMasterBean getItemid(int itemid) {
		
		co = new CollectibleOps();
		
		return co.getFacultyid
							(itemid);
	}
	
	
	
	
	
	
	// --------- SEARCH METHODS --------- //
	
	
	public CollectibleMasterBean searchCollectibleMaster(String searchString) throws SQLException{
		
		co = new CollectibleOps();
		
		return co.searchCollectibleMaster
								(searchString);
	}
	
	
	
	
	

}
